from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime

class TechnologyTagBase(BaseModel):
    name: str = Field(..., min_length=1, max_length=100, description="标签名称")
    description: Optional[str] = Field(None, description="标签描述")
    style: Optional[str] = Field(None, max_length=255, description="前端样式（如颜色、类名等）")
    remark: Optional[str] = Field(None, max_length=255, description="备注信息")
    created_by: Optional[str] = Field(None, max_length=50, description="创建人")
    updated_by: Optional[str] = Field(None, max_length=50, description="更新人")

class TechnologyTagCreate(TechnologyTagBase):
    pass

class TechnologyTagUpdate(BaseModel):
    name: Optional[str] = Field(None, min_length=1, max_length=100, description="标签名称")
    description: Optional[str] = Field(None, description="标签描述")
    style: Optional[str] = Field(None, max_length=255, description="前端样式（如颜色、类名等）")
    remark: Optional[str] = Field(None, max_length=255, description="备注信息")
    updated_by: Optional[str] = Field(None, max_length=50, description="更新人")

class TechnologyTagInDB(TechnologyTagBase):
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True

class TechnologyTagList(BaseModel):
    total: int
    items: list[TechnologyTagInDB]

class TechnologyTagFilter(BaseModel):
    name: Optional[str] = None
    search: Optional[str] = None
    page: int = Field(default=1, ge=1)
    page_size: int = Field(default=10, ge=1, le=100) 